const Router = require('koa-router')
const { uploadAvatar, updateAvatar, savePictureInfo } = require('../controller/file.controller')
const { verifyAuth, verifyPermission } = require('../milldleware/auth.middleware')
const { avatarHandler, pictureHandler, pictureResize } = require('../milldleware/file.milldleware')

const fileRouter = new Router({ prefix: '/upload' })

// 创建头像
fileRouter.post('/avatar', verifyAuth, avatarHandler, uploadAvatar)
// 修改用户头像
fileRouter.post('/:avatarId/avatar', verifyAuth, verifyPermission, avatarHandler, updateAvatar)
// 添加图片
fileRouter.post('/picture', verifyAuth, pictureHandler, pictureResize, savePictureInfo)




module.exports = fileRouter
